package com.wyf.video.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import android.widget.ImageView
import android.widget.TextView
import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.wyf.video.R
import com.wyf.video.model.Bt
import org.jetbrains.anko.find

/**
 * Created by Administrator on 2017/11/6.
 */
class NewAdapter(context: Context?,list:List<Bt> ): BaseAdapter(){

    var context:Context?
    var list:List<Bt>
    init {
        this.context = context
        this.list = list
    }

    override fun getView(p0: Int, p1: View?, p2: ViewGroup?): View {

        var root = LayoutInflater.from(context).inflate(R.layout.item_list_ver,null)
        root.find<TextView>(R.id.new_text_name).text = list[p0].name
        root.find<TextView>(R.id.new_text_score).text = list[p0].score
        var imgPoster = root.find<ImageView>(R.id.new_img_poster)
        Glide.with(context).load(list.get(p0).poster).diskCacheStrategy(DiskCacheStrategy.ALL).into(imgPoster)
        return root
    }

    override fun getItem(p0: Int): Any {
        return p0
    }

    override fun getItemId(p0: Int): Long {
        return p0.toLong()
    }

    override fun getCount(): Int {
        return list.size
    }

}